package com.neuedu.controller;

import com.neuedu.entity.Meal;
import com.neuedu.service.MealService;
import com.neuedu.vo.MealVo;
import com.neuedu.vo.ResultJson;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 膳食日历表 前端控制器
 * </p>
 *
 * @author wangyu
 * @since 2025-10-21
 */
@RestController
@RequestMapping("/meal")
public class MealController {
    @Resource
    MealService mealService;
    @PostMapping("/add")
    ResultJson<Boolean> add(Meal meal) {
        return ResultJson.success(mealService.add(meal), "添加膳食成功");
    }
    @GetMapping("/list")
    ResultJson<List<MealVo>> list() {
        return ResultJson.success(mealService.getList());
    }
    @PostMapping("/delete")
    ResultJson<Boolean> delete(Integer id) {
        return ResultJson.success(mealService.del(id), "删除膳食成功");
    }
    @GetMapping("/getById")
    ResultJson<Meal> getById(Integer id) {
        return ResultJson.success(mealService.getById(id));
    }
    @PostMapping("/update")
    ResultJson<Boolean> update(Meal meal) {
        return ResultJson.success(mealService.update(meal), "更新膳食成功");
    }
}
